package com.nbjtjc.safe.mapper.edu;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.nbjtjc.safe.model.edu.EduDailyExamineList;
import com.nbjtjc.safe.model.edu.EduDailyExamineScore;
import com.nbjtjc.util.MyMapper;
@Mapper
public interface EduDailyExamineScoreMapper extends MyMapper<EduDailyExamineScore> {
	
	List<EduDailyExamineScore> search(@Param("edes")EduDailyExamineScore eduDailyExamineScore);
	
	List<EduDailyExamineScore> searchDetail(@Param("edes")EduDailyExamineScore eduDailyExamineScore);
	
	@Delete("DELETE FROM edu_daily_examine_score WHERE examine_id = #{examId}")
	int deleteByExamId(@Param("examId")int examId);

	@Insert("INSERT INTO edu_daily_examine_score(examine_id,user_id) (SELECT #{edel.id} AS examine_id,user_id FROM edu_daily_participant WHERE `edu_daily_info_id` IN (SELECT info_id FROM edu_daily_record  WHERE id = #{edel.recordId}))")
	int insertByExamList(@Param("edel")EduDailyExamineList eduDailyExamineList);
	
//	@Select("select * from edu_daily_examine_score where examine_id = #{examId}")
	List<EduDailyExamineScore> findByExamId(@Param("examId")int  examId);
	
	List<EduDailyExamineScore> findDetailByExamId(@Param("examId")int  examId);
	
	@Update("update edu_daily_examine_score set cancel = 1 where examine_id = #{examId}")
	int cancelByExamId(@Param("examId") int examId);
}